using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Data;
using System.Data.Common;
using System.ComponentModel;

namespace Tilver.DBConnectionUI.MySQL
{

    internal class MySQLStringBuilder : Tilver.DBConnectionUI.UDLStringBuilder
    {
        public MySQLStringBuilder()
        {
            DataSource = "localhost";
            Port = 3306;
            InitialCatalog = "mysql";
            ConnectionTimeout = 15;
            IgnorePrepare = true;
            Protocol = "socket";
            AllowBatch = true;
            SharedMemoryName = "MYSQL";
            PipeName = "mysql";
            ProcedureCache = 25;
            UseProcedureBodies = true;
            MaxPoolSize = 100;
            Pooling = true;
            ResetPooledConnections = true;

            RegisterAliases();
        }

        void RegisterAliases()
        {
            RegisterAlias("Datasource", "Data Source");
            RegisterAlias("Host", "Data Source");
            RegisterAlias("Server", "Data Source");
            RegisterAlias("Address", "Data Source");
            RegisterAlias("Addr", "Data Source");
            RegisterAlias("Network Address", "Data Source");
            //RegisterAlias("Database", "Initial Catalog");
            RegisterAlias("Database", "Database");
            RegisterAlias("Username", "User Id");
            RegisterAlias("User Name", "User Id");
            RegisterAlias("Uid", "User Id");
            RegisterAlias("Pwd", "Password");
            RegisterAlias("Oldsyntax", "Old Syntax");
            RegisterAlias("Pipe", "Pipe Name");
            RegisterAlias("ResetConnections", "Reset Pooled Connections");
            RegisterAlias("ResetPooledConnections", "Reset Pooled Connections");
            RegisterAlias("CacheServerConfiguration", "Cache Server Configuration");
            RegisterAlias("CacheServerConfig", "Cache Server Configuration");
        }



        #region Properties

        [DisplayName("Data Source"), Category("Connection")]
        public string DataSource { get; set; }

        [DefaultValue(3306), DisplayName("Port"), Category("Connection")]
        public int Port { get; set; }

        //[DisplayName("Initial Catalog"), Category("Connection")]
        [DisplayName("Database"), Category("Connection")]
        public string InitialCatalog { get; set; }

        [DisplayName("User Id"), Category("Security")]
        public string UserID { get; set; }

        [DisplayName("Password"), Category("Security"), PasswordPropertyText(true)]
        public string Password { get; set; }

        [DefaultValue(false), DisplayName("Persist Security Info"), Category("Security")]
        public bool PersistSecurityInfo { get; set; }

        [DefaultValue(15), DisplayName("Connection Timeout"), Category("Advanced")]
        public int ConnectionTimeout { get; set; }

        [DefaultValue(true), DisplayName("Ignore Prepare"), Category("Advanced")]
        public bool IgnorePrepare { get; set; }

        [DefaultValue("socket"), DisplayName("Protocol"), Category("Connection")]
        public string Protocol { get; set; }

        [DefaultValue(""), DisplayName("Character Set"), Category("Advanced")]
        public string CharacterSet { get; set; }

        [DefaultValue(false), DisplayName("Logging"), Category("Advanced")]
        public bool Logging { get; set; }

        [DefaultValue(true), DisplayName("Allow Batch"), Category("Advanced")]
        public bool AllowBatch { get; set; }

        [DefaultValue(false), DisplayName("Encrypt"), Category("Advanced")]
        public bool Encrypt { get; set; }

        [DefaultValue("MYSQL"), DisplayName("Shared Memory Name"), Category("Advanced")]
        public string SharedMemoryName { get; set; }

        [DefaultValue(false), DisplayName("Allow Zero Datetime"), Category("Advanced")]
        public bool AllowZeroDatetime { get; set; }

        [DefaultValue(false), DisplayName("Convert Zero Datetime"), Category("Advanced")]
        public bool ConvertZeroDatetime { get; set; }

        [DefaultValue(false), DisplayName("Old Syntax"), Category("Advanced")]
        public bool OldSyntax { get; set; }

        [DefaultValue("mysql"), DisplayName("Pipe Name"), Category("Advanced")]
        public string PipeName { get; set; }

        [DefaultValue(25), DisplayName("Procedure Cache"), Category("Advanced")]
        public int ProcedureCache { get; set; }

        [DefaultValue(true), DisplayName("Use Procedure Bodies"), Category("Advanced")]
        public bool UseProcedureBodies { get; set; }

        [DefaultValue(0), DisplayName("Connection Lifetime"), Category("Pooling")]
        public int ConnectionLifetime { get; set; }

        [DefaultValue(100), DisplayName("Max Pool Size"), Category("Pooling")]
        public int MaxPoolSize { get; set; }

        [DefaultValue(0), DisplayName("Min Pool Size"), Category("Pooling")]
        public int MinPoolSize { get; set; }

        [DefaultValue(true), DisplayName("Pooling"), Category("Pooling")]
        public bool Pooling { get; set; }

        [DefaultValue(true), DisplayName("Reset Pooled Connections"), Category("Pooling")]
        public bool ResetPooledConnections { get; set; }

        [DefaultValue(false), DisplayName("Cache Server Configuration"), Category("Pooling")]
        public bool CacheServerConfiguration { get; set; }
        #endregion

    }

}
